package com.lulu.baselib.util;

import android.text.SpannableString;
import android.text.Spanned;
import android.text.SpannedString;
import android.text.style.AbsoluteSizeSpan;
import android.widget.TextView;

/**
 * Author: XuChang
 * Date: 2019/10/25 22:55
 * Email: 123286473@qq.com
 * Description:修改text和editText hint文字大小
 * History:
 */
public class HintUtil {

    /**
     *  修改文字的hint值，也可用于editView
     * @param textView
     * @param sp
     */
    public static void changeHintSize(TextView textView, int sp){
        String hint = textView.getHint().toString();
        SpannableString ss = new SpannableString(hint);
        AbsoluteSizeSpan ass = new AbsoluteSizeSpan(DimensUtil.sp2px(textView.getContext(),sp),true);
        ss.setSpan(ass,0,ss.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        textView.setHint(new SpannedString(ss));
    }
}
